package com.zhiyou.reflection2;

import java.lang.reflect.Method;

public class Test {


    public static void main(String[] args) throws Exception {
        //要得到他的Class类型的对象
//        Class<Person> clazz = Person.class; //获取Person 的Class 类型的对象
//
//        //实例化对象
//        Person person = clazz.newInstance();
//        person.setAddress("China");
//
//        System.out.println(person.getAddress());
        //第二种
        Class<?> clazz = Class.forName("com.zhiyou.reflection2.Person");


        Method method2 = clazz.getDeclaredMethod("yiqi", String.class, String.class);
        method2.setAccessible(true);
            System.out.println(method2.toGenericString());

        Object invoke = method2.invoke(clazz.newInstance(), "sss", "ss");
        System.out.println(invoke);
        System.out.println("invoke = " + invoke);

    }
}
